/**进度工具 */
import Ora from "ora";
/**进度菊花 */
export default class MSpinner {
  private static ora: Ora.Ora | null = null;
  /**开始显示 */
  public static start(text: string) {
    if (!MSpinner.ora) MSpinner.ora = Ora();
    MSpinner.ora.start(text);
  }
  /**停止显示 */
  public static stop() {
    if (!MSpinner.ora) return;
    MSpinner.ora.stop();
  }
  /**操作成功 */
  public static success(text: string) {
    if (!MSpinner.ora) MSpinner.ora = Ora();
    MSpinner.ora.succeed(text);
  }
  /**操作失败 */
  public static fail(err: string) {
    if (!MSpinner.ora) MSpinner.ora = Ora();
    MSpinner.stop();
    MSpinner.ora.fail(err);
  }
}
